<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>
<script>
    function check_repeat_listorders(){
    	var listorders = new Array();
    	var list_flag = 0;
    	$(".list_orders").each(function(i){
    		listorders[i] = $(this).val();
        });
    	var nary=listorders.sort(); 
    	for(var i=0;i<listorders.length;i++){
        	if (nary[i]==nary[i+1]){ 
     		   alert("排序字段不能出现重复值："+nary[i]); 
     		   list_flag = 1;
        	}
    	}
    	if(list_flag!=1){
    		myform.action='?m=pass_game&c=manage&a=listorder&dosubmit=1';myform.submit();
        }
    }
</script>
<div class="subnav">
	<div class="content-menu ib-a blue line-x">
		<a href="./index.php?m=pass_game&c=manage&a=init" class="on"><em><?php echo L('column')?>列表</em></a>
		<span>|</span>

		<?php if(isset($_GET['id'])){?>
			<a href="./index.php?m=pass_game&c=manage&a=add"><em>添加</em></a>
			<span>|</span>
			<a href="./index.php?m=pass_game&c=manage&a=init" ><em>返回上一级</em></a>
		<?php }else{?>
			<a href="./index.php?m=pass_game&c=manage&a=add"><em><?php echo L('column')?>添加</em></a>
		<?php }?>
	</div>
</div>

<div class="pad-lr-10">
	<form name="searchform" action="" method="get">
		<input type="hidden" value="pass_game" name="m">
		<input type="hidden" value="manage" name="c">
		<input type="hidden" value="init" name="a">
		<?php if(isset($_GET['id'])){?>
			<input type="hidden" value="<?=$_GET['id']?>" name="id">
		<?php }?>
		<table width="100%" cellspacing="0" class="search-form">
			<tbody>
			<tr>
				<td>
					<div class="explain-col">
						<?php echo L('name');?>：<input name="name" type="text" value="<?php if(isset($_GET['name'])) {echo $_GET['name'];}?>"
										 class="input-text" />
						<input type="submit" name="search"  class="button" value="<?php echo L('search')?>" />
						<a style="float:right;cursor:pointer;" href="javascript:;" onclick="refreshData(9);" class="button">刷新数据</a>
					</div>
				</td>
			</tr>
			</tbody>
		</table>
	</form>


	<form name="myform" action="?m=pass_game&c=manage&a=del" method="post"
		onsubmit="return confirm('<?php echo L('confirm')?>')">
		<div class="table-list">
			<table width="100%" cellspacing="0">
				<thead>
					<tr>
						<th align="center" width="20"><input type="checkbox" value=""
							id="check_box" onclick="selectall('id[]');"></th>
						<th align="center" width="20"><?php echo L('listorder');?></th>
						<th align="center" width="20">ID</th>
						<th align="center" width="50"><?php echo L('name');?></th>
						<th align="center" width="80"><?php echo L('logo');?></th>
						<th align="center" width="60"><?php echo L('limit_second');?></th>
						<th align="center" width="80"><?php echo L('share_second');?></th>
						<th align="center" width="80"><?php echo L('success_couple');?></th>
						<th align="center" width="80"><?php echo L('pic_num');?></th>
						<th align="center" width="110"><?php echo L('share_title');?></th>
						<th align="center" width="110"><?php echo L('description');?></th>
						<th align="center" width="80"><?php echo "上次编辑者"; ?></th>
						<th align="center" width="100"><?php echo "操作"?></th>
					</tr>
				</thead>
				<tbody>
<?php
if(!empty($gameinfo)){
foreach ($gameinfo as $k => $v) {
    ?>
    <tr>
						<td align="center"><input type="checkbox"
							value="<?php echo $v['id']?>" name="id[]"></td>
						<td align='center'><input name='listorders[<?php echo $v['id'];?>]' type='text' size='3' value='<?php echo $v['list_order'];?>' class='input-text-c list_orders'></td>
						<td align="center"><?php echo $v['id'];?></td>
						<td align="center"><?php  if(!empty($v['name'])){echo $v['name'];}else{echo"<span style='color:red;'>（未设置）</span>";}?></td>
						<td align="center"><?php if(isset($v['logo']) && !empty($v['logo'])){?><img src="<?=$v['logo']?>"  height="60" /><?php }else{echo "<span style='color:red;'>（未设置）</span>";}?></td>
						<td align="center"><?php if(!empty($v['limit_second'])){echo '<strong>'.$v['limit_second'].'</strong>&nbsp;秒';}else{echo"<span style='color:red;'>（未设置）</span>";}?></td>
						<td align="center"><?php if(!empty($v['share_second'])){echo '<strong>'.$v['share_second'].'</strong>&nbsp;秒';}else{echo"<span style='color:red;'>（未设置）</span>";}?></td>
						<td align="center"><?php if(!empty($v['success_couple'])){echo '<strong>'.$v['success_couple'].'</strong>&nbsp;对';}else{echo"<span style='color:red;'>（未设置）</span>";}?></td>
						<td align="center"><?php if(!empty($v['pic_num'])){echo '<strong>'.$v['pic_num'].'</strong>&nbsp;个';}else{echo"<span style='color:red;'>（未设置）</span>";}?></td>
						<td align="center" title="<?=$v['share_title']?>"><?php if(!empty($v['share_title'])){echo $v['share_title'];}else{echo"<span style='color:red;'>（未设置）</span>";}?></td>
						<td align="center" title="<?=$v['description']?>"><?php if(!empty($v['description'])){echo $v['description'];}else{echo"<span style='color:red;'>（未设置）</span>";}?></td>
						<td align="center"><?php if(!empty($v['publisher'])){echo $v['publisher'];}else{echo"<span style='color:red;'>（未设置）</span>";}?></td>
						<td align="center">
							<a  href="?m=pass_game&c=manage&a=edit&id=<?php echo $v['id']?>"><?php echo  L("edit");?></a>&nbsp;|&nbsp;
							<a href="?m=pass_game&c=manage&a=del&id=<?php echo $v['id']?>&name=<?php echo $v['name'];?>"
							onClick="return confirm('<?php echo L('confirm')?>')"><?php echo  L("del")  ?></a>
                        </td>
					</tr>
<?php
}
}else{
    echo "<tr><td colspan='12' style='color:red;font-size:18px;text-align:center;'><span>暂无数据！</span></td></tr>";
}
?>
</tbody>
			</table>

			<div class="btn">
				<label for="check_box"><a href="#"
					onClick="javascript:$('input[type=checkbox]').attr('checked', true)"><?php echo L('select_all')?></a>/<a
					href="#"
					onClick="javascript:$('input[type=checkbox]').attr('checked', false)"><?php echo L('cancel')?></a></label>
			   <input type="button" class="button" value="<?php echo L('listorder');?>" onclick="check_repeat_listorders();"/>
				<input type="submit" class="button" name="dosubmit"
					value="<?php echo L('delete')?>" />
			</div>

<div id="pages"><?php echo $pages?></div>
		</div>
	</form>
</div>
</body>
</html>